/**
 * grayrabbit Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */
package com.grayrabbit.slacker.gengerate;

import java.util.Map;

import com.grayrabbit.slacker.config.GenerateConfig;
import com.grayrabbit.slacker.interfaces.CodeGenerate;
import com.grayrabbit.slacker.utils.TemplateProcessUtils;

/**
 * manager实现类生成工具类
 * 
 * @author liyd
 * @version $Id: ManagerImplGenerate.java, v 0.1 2012-5-15 下午1:54:57 liyd Exp $
 */
public class ManagerImplGenerate extends NormalGenerate implements CodeGenerate {

    /** 
     * @see com.grayrabbit.slacker.interfaces.CodeGenerate#generate(com.grayrabbit.slacker.config.GenerateConfig, java.util.Map)
     */
    public void generate(GenerateConfig generateConfig, Map<String, String> modelMap) {

        super.normalDataInit(generateConfig);

        //不包含包名
        String interfaceClassName = this.getClassName(MANAGER_QUALIFIED_CLASS_NAME);

        //不包含包名
        String serviceClassName = this.getClassName(SERVICE_QUALIFIED_CLASS_NAME);

        StringBuilder sbImport = new StringBuilder();
        sbImport.append("import " + MANAGER_QUALIFIED_CLASS_NAME + ";");
        sbImport.append("\r\n");
        sbImport.append("import " + this.ENTITY_QUALIFIED_CLASS_NAME + ";");
        sbImport.append("\r\n");
        sbImport.append("import " + SERVICE_QUALIFIED_CLASS_NAME + ";");

        modelMap.put("import", sbImport.toString());

        modelMap.put("package", this.PACKAGE);

        modelMap.put("className", this.getClassName(TARGET_QUALIFIED_CLASS_NAME));

        modelMap.put("interfaceName", interfaceClassName);

        modelMap.put("serviceDefine", serviceClassName);

        modelMap.put("serviceInstance", TemplateProcessUtils.convertFirstLower(serviceClassName));

        modelMap.put("entityClass", this.getClassName(ENTITY_QUALIFIED_CLASS_NAME));

        modelMap.put("entityClassInstance",
            TemplateProcessUtils.convertFirstLower(this.getClassName(ENTITY_QUALIFIED_CLASS_NAME)));

        modelMap.put("gmtCreate", this.GMT_CREATE);

    }

}
